home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir31 / gusutils.zip / GUSDUMP.PAS < prev    next >
Pascal/Delphi Source File  |  1994-02-08  |  5KB  |  193 lines

  1. (****************************************************************************)
  2. (* Module     : GUSDUMP.PAS                                                 *)
  3. (* Verion     : 0.3ß                                                        *)
  4. (* Date       : Thu Feb 3, 1994                                             *)
  5. (* Pascal     : TP 7.0                                                      *)
  6. (****************************************************************************)
  7. (*                                                                          *)
  8. (* NOTICE OF COPYRIGHT AND OWNERSHIP OF SOFTWARE:                           *)
  9. (*                                                                          *)
  10. (* Portions Copyright (C) 1993, 1994 by MESS Computer Services.             *)
  11. (* Copyright (C) 1993, 1994 by TBP Electronics Ltd.                         *)
  12. (* All rights reserved.                                                     *)
  13. (*                                                                          *)
  14. (****************************************************************************)
  15. (* MESS Computer Services V.O.F.        MM   MM  EEEEEE   SSSSS   SSSSS     *)
  16. (* Jadestraat 54                        M M M M  E       S       S          *)
  17. (* 4817 JK  Breda                       M  M  M  EEEE     SSSS    SSSS      *)
  18. (* The Netherlands                      M     M  E            S       S     *)
  19. (*                                      M     M  EEEEEE  SSSSS   SSSSS      *)
  20. (* Tel: +31-76 22 34 31                                                     *)
  21. (* Fax: +31-76 20 46 23               Many Efforts for Structured Systems   *)
  22. (* Email: appel@stack.urc.tue.nl                                            *)
  23. (****************************************************************************)
  24.  
  25.  
  26. {$A-,B-,D+,E-,F-,G+,I-,L+,N-,O-,P-,Q-,R-,S-,T-,V-,X+}
  27. {$M 4096,0,0}
  28.  
  29. Program GUSDump;
  30. {
  31.   dumps memory form a ultrasound card on the screen
  32.     possible parameters are
  33.         0 - fffff   hex start location
  34.     -x          hex dump
  35.     -l          number of lines
  36.     default start location is 0
  37.     default number of lines is 16
  38. }
  39.  
  40. uses
  41.     dos,
  42.     gus,
  43.     crt;
  44.  
  45. const
  46.     Hex : array [0..15] of Char = '0123456789ABCDEF';
  47.  
  48. var
  49.     Teller  ,
  50.     Tel2    : Word;
  51.     Value   : Byte;       { read value from dram }
  52.     Start   : LongInt;    { start of dump }
  53.     Dhex    : Boolean;    { display hex or chars }
  54.     Fault   : Boolean;    { fault occured, 0 = no fault, 1 = parameters, }
  55.     Lines   ,             { number of lines }
  56.     Col     : Word;       { number of colums on screen }
  57.  
  58. { ---------------------- }
  59.  
  60. function HexAdd (L : LongInt) : String;
  61. var
  62.     St : String;
  63. begin
  64.     St := '00000';
  65.  
  66.     St[1] := Hex[L and $F0000 shr 16];
  67.     St[2] := Hex[L and $0F000 shr 12];
  68.     St[3] := Hex[L and $00F00 shr  8];
  69.     St[4] := Hex[L and $000F0 shr  4];
  70.     St[5] := Hex[L and $0000F shr  0];
  71.  
  72.     HexAdd := St;
  73. end;
  74.  
  75. { ------------------ }
  76.  
  77. function HexByte (B : Byte) : String;
  78. var
  79.     St : String;
  80. begin
  81.     St := '00';
  82.  
  83.     St[1] := Hex[B and $000F0 shr  4];
  84.     St[2] := Hex[B and $0000F shr  0];
  85.  
  86.     HexByte := St;
  87. end;
  88.  
  89. { ------------------ }
  90.  
  91. procedure evalparm;
  92. var
  93.     Tel      ,
  94.     Tel1     ,
  95.     Tel2     : word;
  96.     Eigen    : string;
  97.     First    : boolean;
  98. begin
  99.     First := True;
  100.     for Tel := 1 to ParamCount do
  101.     begin
  102.         Eigen := ParamStr(tel);
  103.         for Tel1 := 1 to Length(Eigen) do
  104.             Eigen[Tel1] := UpCase(Eigen[Tel1]);
  105.         if (Eigen[1] = '-') and (Eigen[2] = 'L') then
  106.         begin
  107.             { count lines }
  108.             Delete(Eigen,1,2);
  109.             Val(Eigen, Lines, Lines);
  110.             if Lines <> 0
  111.                 then DEC(Lines)
  112.                 else Lines := 16;
  113.         end
  114.             else
  115.         begin
  116.             if (Eigen = '-X') then Dhex := True
  117.                 else
  118.             begin
  119.                 if (NOT(Fault) and First) then
  120.                 begin
  121.                     First := False;
  122.                     Eigen := '$' + Eigen;
  123.                     Val (Eigen, Start, Tel2);
  124.                     if (Start > $FFFFF) then Start := -1;
  125.                     if (Start > $FFFFF - 1215) then Start := $FFFFF - 1215;
  126.                 end
  127.                     else
  128.                 Fault := True;
  129.         end; end; end;
  130. end;
  131.  
  132. { ------------------------ }
  133.  
  134. begin
  135.     clrscr;
  136.     WriteLn ('Gravis UltraSound Memory Dump     v0.3ß');
  137.     WriteLn ('(C)CopyRight 1993-1994, TBP Electronics');
  138.     writeln;
  139.  
  140.     Dhex   := False;
  141.     Fault  := False;
  142.     Lines  := 16;
  143.     Start  := 0;
  144.  
  145.     evalparm;
  146.  
  147.     if Dhex then
  148.         Col := 16
  149.     else
  150.         Col := 64;
  151.  
  152.     if MegaEm then
  153.     begin
  154.         WriteLn ('Mega-Em from Jayeson Lee-Steere is active, sorry cant read GUS DRAM');
  155.     end else begin
  156.  
  157.     IF Fault then
  158.     begin
  159.         WriteLn ('Usage : GUSDUMP  [hex start address 0 - FFFFF] [-X] [-L#]');
  160.     end else begin
  161.  
  162.     If Dhex then
  163.     begin
  164.             WriteLn ('        0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F');
  165.     end
  166.         else
  167.     begin
  168.         WriteLn ('       0               1               2               3');
  169.         WriteLn ('       0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF');
  170.     end;
  171.  
  172.     for Teller := 0 to lines do
  173.     begin
  174.         Write ( HexAdd(start + (teller * col)) );
  175.         Write ('  ');
  176.         for tel2 := 0 to col -1 do
  177.         begin
  178.             value := Guspeek(Start + (teller * col) + tel2);
  179.             if Dhex then
  180.             begin
  181.                 write(HexByte(value), ' ');
  182.             end
  183.                 else
  184.             begin
  185.                 if (value > 31)
  186.                     then write(chr(value))
  187.                     else write(' ');
  188.             end;
  189.         end;
  190.     writeln;
  191.     end; end; end;
  192. end.
  193.